function initApproveInfo(data){
	//提交人身份置为不可用
	$(".workflow-opt-start-tr").css("display","none");
	//初始化流程实例ID
	$(".proInsId").val(data.proInsId);
	//加载流程审批记录
	$("#flowOpinions").attr("src",PATH+"/bpm/workflow/opinions?proInstID="+data.proInsId); 
	//初始化流程执行信息
	var bpm_flow_excute_type = data.bpm_flow_excute_type;
	if(bpm_flow_excute_type){
		$("#bpm_flow_excute_type").val(bpm_flow_excute_type);
	}
	initWorkFlowInfo(data);
	$("#taskId").val(data.taskId);
	if(data.workFlowStatus == "end"){
		$(".workflow-show-tr").css("display","none");
		$(".workflow-opt-task-tr").css("display","none");
		$("#workflow-admin-tr").css("display","none");
		$(".att-show").css("display","none");
		$("#workFlowEnd").css("display","");
	}else{
		var isopt = data.isopt;
		$("#workflow-admin-tr").css("display","");
		if(isopt){
			$("#is_work_flow_").val(true);
			//展示操作信息
			$(".workflow-opt-task-tr").css("display","");
			$(".att-show").css("display","");
			if($(".att-show").find("input[name='soureBillID']")[0]){
				$($(".att-show").find("input[name='soureBillID']")[0]).val(data.taskId);
			}
			initWorkFlowOpt(data);
		}else{
			$(".workflow-opt-task-tr").css("display","none");
			$(".att-show").css("display","none");
			if(data.curTaskUrl){
				$(".curTaskUrl-tr").css("display","");	
				$("#hisuser_td").html('<a href="'+PATH+data.curTaskUrl+'">调转</a>');
			}
		}
	}
	//加载流程图
	var diagram_url = PATH+"/bpm/workflow/queryFlowImage?";
	diagram_url += "defId="+data.defId;
	if(data.proInsId){
		diagram_url += "&instanceId="+data.proInsId;
		$("#adminOptJsp").attr("src",PATH+"/bpm/bpmsap/admin/"+data.proInsId);
	}
	$("#diagram_iframe").attr("src",diagram_url); 
}

//验证FORM表单
function validateForm() {
	var actionName = $("input[name='actionName']:checked").val();
	var nodeId = $("input[name='nodeId']:checked").val();
	if(actionName == "agree" && $('input[name="nodeId"]').length > 1 && (nodeId == '' || nodeId == undefined)) {
		alert("请选择下一节点任务！");
		return false;
	} 
	var s = document.getElementById("editNode-admin-tr").style.display;
	if( s != "none" && $("#editNodeIds").length != 0 && ($("#editNodeIds").val() == '' || $("#editNodeIds").val() == undefined)) {
		alert("请设置节点处理人！");
		return false;
	}
	return true;
}

function initWorkFlowInfo(data){
	var workflowinfo = data.workflowinfo;
	if(workflowinfo){
		workflowinfo = jQuery.parseJSON(workflowinfo);
		if(workflowinfo.extUser){
			$("#extUser_td").html("<span>"+workflowinfo.extUser+"</span>");
		}
		if(workflowinfo.nodeDefName){
			$("#nodeDefName_td").html("<span>"+workflowinfo.nodeDefName+"</span>");
		}
		if(workflowinfo.outcomeNodes){
			$("#outcomeNodes_td").html("<span>"+workflowinfo.outcomeNodes+"</span>");
		}
	}
}

function initWorkFlowOpt(data){
	var workflowOpt = data.workflowOpt;
	var workflowinfo = data.workflowinfo;
	if(workflowOpt){
		workflowOpt = jQuery.parseJSON(workflowOpt);
		var td_info = "";
		$(workflowOpt).each(function(){
			if(this.btnKey == "agree"){
				td_info += '<input type="radio" name="actionName" checked="checked" value="'+this.btnKey+'" onclick="actionChange(this)" />'+this.btnName;	
			}else{
				td_info += '<input type="radio" name="actionName" value="'+this.btnKey+'" onclick="actionChange(this)" />'+this.btnName;	
			}
		}); 
		$("#opt-actionName").html(td_info);
	}
	if(workflowinfo){
		workflowinfo = jQuery.parseJSON(workflowinfo);
		if(workflowinfo.outcomeNodeIds && workflowinfo.outcomeNodes){
			var nodeIdArray = workflowinfo.outcomeNodeIds.split(";");
			var nodeNameArray = workflowinfo.outcomeNodes.split(";");
			var td_info = "";
			if(nodeIdArray.length == 1) {
				$("#opt-nextNode-tr").css("display","none");
			} else {
				for(var i = 0 ; i < nodeIdArray.length ; i++) {
					td_info += '<input type="radio" name="nodeId" value="'+nodeIdArray[i]+'"  />'+nodeNameArray[i];
				}
				$("#opt-nextNode").html("<span>"+td_info+"</span>");
			}
		}
	}
	initEditNodeInfo(data);
}

//初始化可编辑节点信息
function initEditNodeInfo(data) {
	var editNodeInfo = data.editNodeInfo;
	editNodeInfo = jQuery.parseJSON(editNodeInfo);
	if(editNodeInfo.isEditNode){
		var hidden_info = "";
		hidden_info += '<input type="hidden" name="editNodeIds" id="editNodeIds"> ';
		hidden_info += '<input type="hidden" name="userIds" id="userIds"> ';
		$("#editNode-admin-tr").append(hidden_info);
		$("#editNode-admin-tr").css("display","");
		$("#editNodeAdminOptJsp").attr("src",PATH+"/bpm/bpmsap/editNodeAdmin/"+data.defId+"/"+editNodeInfo.nodeId);
	}
}

//根据审批意见控制下一节点任务的显示
function actionChange(obj) {
	if(obj.value == "agree") {
		if($('input[name="nodeId"]').length > 1) {
			$("#opt-nextNode-tr").css("display","");
		}
		if($("#editNode-admin-tr").length != 0) {
			$("#editNode-admin-tr").css("display","");
		}
	} else {
		$("#opt-nextNode-tr").css("display","none");
		if($("#editNode-admin-tr").length != 0) {
			$("#editNode-admin-tr").css("display","none");
		}
	}
}

//设置常用意见
function setOpinion(obj){
	$("#opinionIdea").val($("#generalOpinions").val());
}

function error(data){
	
}
